package com.aote.model.block;

import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;

import com.browsesoft.Tools;

/**
 * 数据块条件对象
 * 
 */
public class DataBlockCondition {

	/**
	 * 条件
	 */
	private Map conditions = new HashMap();

	/**
	 * 属性名
	 */
	private String name = "";

	public DataBlockCondition(String condition) {
		List list = Tools.stringToLinkedList(condition, '.');
		setConditionsAndName(list);
	}

	/**
	 * 设置条件和名称
	 */
	private void setConditionsAndName(List list) {
		Iterator iter = list.iterator();
		while (iter.hasNext()) {
			String str = (String) iter.next();
			if (str.indexOf("=") != -1) {
				int index = str.indexOf("=");
				String key = str.substring(0, index);
				String value = str.substring(index + 1, str.length());
				this.conditions.put(key, value);
			} else {
				this.name = str;
			}
		}
	}

	/**
	 * 得到条件
	 */
	public Map getConditions() {
		return this.conditions;
	}

	/**
	 * 得到名称
	 */
	public String getName() {
		return this.name;
	}

}
